import 'package:flutter/material.dart';
import 'package:zchope_student/apis.dart';
import 'package:zchope_student/const.dart';
import 'package:zchope_student/utils/mydio.dart';

class CommonProblem extends StatefulWidget {
  @override
  _CommonProblemState createState() => _CommonProblemState();
}

class _CommonProblemState extends State<CommonProblem> {
  var _controllerKey = new TextEditingController();

  void _hotsProblem() async {
    MyDio.getInstance(url: Const.BASEURL2).get(Apis.hots, (data) async {
      print(data);
      setState(() {
        if (data['resultCode'] == 0) {
          //成功
        }
      });
    });
  }

  @override
  void dispose() {
    // TODO: implement dispose
    super.dispose();
    MyDio.getInstance().clearInstance();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text('常见问题'),
          centerTitle: true,
        ),
        body: Padding(
          padding: EdgeInsets.symmetric(horizontal: 20, vertical: 30),
          child: Column(
            children: <Widget>[
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: <Widget>[
                  TextFormField(
                    controller: _controllerKey,
                    onChanged: (value) {},
                    style: TextStyle(fontSize: 16, color: Colors.grey),
                    decoration: InputDecoration(
                        contentPadding: const EdgeInsets.fromLTRB(64, 8, 0, 8),
                        hintText: '请输入关键字',
                        hintStyle:
                            TextStyle(color: Color(0xff999999), fontSize: 16),
                        focusedBorder: OutlineInputBorder(
                            borderRadius: BorderRadius.all(
                              Radius.circular(36),
                            ),
                            borderSide: BorderSide(
                              color: Color(0xff999999),
                              width: 1,
                            )),
                        enabledBorder: OutlineInputBorder(
                            borderRadius: BorderRadius.all(
                              Radius.circular(36),
                            ),
                            borderSide: BorderSide(
                              color: Color(0xff999999),
                              width: 1,
                            ))),
                    autofocus: false,
                  ),
                  GestureDetector(
                    onTap: () {
                      _hotsProblem();
                    },
                    child: Text(
                      '搜索',
                      style: TextStyle(fontSize: 16, color: Color(0xff23AFDC)),
                    ),
                  )
                ],
              ),
              SizedBox(
                height: 10,
              ),
//              WebView(
//                initialUrl: 'http://www.baidu.com',
//              )
            ],
          ),
        ));
  }
}
